	function addquerstions(index,max_xh) {
        if (index != "8") {
        	var movie_box = '<div class="movie_box box_xh is_tj" xh="'+max_xh+'" style="border: 1px solid rgb(255, 255, 255);"></div>'; 
        	var Grade = $(".yd_box").find(".box_xh").length + 1;
       	}else{
       		var movie_box = '<div class="movie_box duanluo_xh is_tj" xh="'+max_xh+'" style="border: 1px solid rgb(255, 255, 255);"></div>';
        	var Grade = '';
       	}
 		
       	var wjdc_list = '<ul class="wjdc_list"></ul>';
        var danxuan = "";
        if(index == "0") {
            danxuan = '【单选】';
            title = '题目';
        } else if(index == "1") {
            danxuan = '【多选】';
            title = '题目';
        } else if(index == "2") {
            danxuan = '【填空】';
            title = '题目';
        } else if(index == "3") {
            danxuan = '【问答】';
            title = '题目';
        } else if (index == "4") {
            danxuan = '【文件】';
            title = '题目';
        } else if (index == "5") {        	
            danxuan = '【姓名】';
            title = '您的姓名：';
        } else if (index == "6") {
            danxuan = '【性别】';
            title = '您的性别：';
        } else if (index == "7") {
            danxuan = '【年龄】';
          	title = '您的年龄段：';
        } else if (index == "8") {
            danxuan = '【段落】';
            title = '题目';
        } else if (index == "10") {
            danxuan = '【比重题】';
            title = '题目';
        } else if (index == "11") {
            danxuan = '【省】';
            title = '您所在的省份：';
        } else if (index == "12") {
            danxuan = '【省-市】';
            title = '请选择城市:';
        } else if (index == "13") {
            danxuan = '【省-市-区】';
            title = '请选择省份城市与地区:';
        } else if (index == "14") {
            danxuan = '【手机号】';
            title = '请输入您的手机号码：';           
        } else if (index == "15") {
            danxuan = '【Email】';
            title = '您常用的Email地址：';
        } else if (index == "16") {
            danxuan = '【出生日期】';
            title = '请输入您的出生日期：';
        } else if (index == "17") {
            danxuan = '【职业】';
            title = '您目前从事的职业：';
        } else if (index == "18") {
            danxuan = '【行业】';
            title = '您目前从事的行业：';
        } else if (index == "19") {
            danxuan = '【评分】';
            title = '题目';
        } else if (index == "20") {
            danxuan = '【单项投票】';
            title = '题目';
        } else if (index == "21") {
            danxuan = '【多项投票】';
            title = '题目';
        }
        if(index != 2 && index != 3 && index != 4 && index != 8){
        	var required = '<i class="is_bt"><font color="red" size="4px">*</font></i>';        	
        }else{
        	var required = '';
        }
       
        if (index != "8") {
       		wjdc_list = $(wjdc_list).append('<li><div class="tm_btitlt">'+required+'<i class="nmb">' + Grade + '</i><i>.</i><i class="btwenzi">'+title+'</i><span class="tip_wz">' + danxuan + '</span></div></li>');
       		wjdc_list = $(wjdc_list).append('<img style="max-height: 200px;" class="add-img imgshow" src="">');
       	}
       	if (index == "0") {
            wjdc_list = $(wjdc_list).append('<li><label class="demo--label" onselectstart="return false;" style="-moz-user-select:none;margin:0;"><input type="radio" name="a" value="" class="demo--radio1" /><span class="demo--radio1Input"></span><span class="demo_span">选项1</span></label></li>');
        	wjdc_list = $(wjdc_list).append('<li><label class="demo--label" onselectstart="return false;" style="-moz-user-select:none;margin:0;"><input type="radio" name="a" value="" class="demo--radio1" /><span class="demo--radio1Input"></span><span class="demo_span">选项2</span></label></li>');               	
        }       
        if (index == "1"){
        	wjdc_list = $(wjdc_list).append('<li><label class="demo--label" onselectstart="return false;" style="-moz-user-select:none;margin:0;"><input type="checkbox" name="a" value="" class="demo--radio" /><span class="demo--radioInput"></span><span class="demo_span">选项1</span></label></li>');
        	wjdc_list = $(wjdc_list).append('<li><label class="demo--label" onselectstart="return false;" style="-moz-user-select:none;margin:0;"><input type="checkbox" name="a" value="" class="demo--radio" /><span class="demo--radioInput"></span><span class="demo_span">选项2</span></label></li>');
        }         
        if (index == "2"){
        	wjdc_list = $(wjdc_list).append('<li><label style="position:relative;"><textarea name="" cols="" rows="" class="input_wenbk btwen_text btwen_text_dx" style="resize:none;max-height:33px;width:98%;"></textarea></label></li>');      	
        }  
        if (index == "3") {
            wjdc_list = $(wjdc_list).append('<li><label><textarea name="" cols="" rows="" class="input_wenbk btwen_text btwen_text_dx"></textarea></label></li>');
        }
       	if (index == "4") {
            wjdc_list = $(wjdc_list).append('<li><label><a href="javascript:;" class="file"><i class="layui-icon layui-icon-upload" style="padding-right:5px;"></i>选择文件<input type="file" name="" id="" style="cursor:pointer;"></a></label></li>');
        }
        if (index == "5") {
            wjdc_list = $(wjdc_list).append('<li><label style="position:relative;"><textarea name="" cols="" rows="" class="input_wenbk btwen_text btwen_text_dx" style="resize:none;max-height:33px;width:26%;padding-left:5%;"></textarea><i style="position:absolute;left:0;top:6px;font-size:20px;color:#999;width:5%;text-align:center;" class="layui-icon layui-icon-friends"></i></label> </li>');
        }
        if (index == "6") {
            wjdc_list = $(wjdc_list).append('<li><label class="demo--label" onselectstart="return false;" style="-moz-user-select:none;margin:0;"><input type="radio" name="a" value="" class="demo--radio1" /><span class="demo--radio1Input"></span><span class="demo_span">男</span></label></li>');
        	wjdc_list = $(wjdc_list).append('<li><label class="demo--label" onselectstart="return false;" style="-moz-user-select:none;margin:0;"><input type="radio" name="a" value="" class="demo--radio1" /><span class="demo--radio1Input"></span><span class="demo_span">女</span></label></li>');
        }                        
        if (index == "7") {
            wjdc_list = $(wjdc_list).append('<li><label class="demo--label" onselectstart="return false;" style="-moz-user-select:none;margin:0;"><input type="radio" name="a" value="" class="demo--radio1" /><span class="demo--radio1Input"></span><span class="demo_span">18岁以下</span></label></li>');
            wjdc_list = $(wjdc_list).append('<li><label class="demo--label" onselectstart="return false;" style="-moz-user-select:none;margin:0;"><input type="radio" name="a" value="" class="demo--radio1" /><span class="demo--radio1Input"></span><span class="demo_span">18~25</span></label></li>');
            wjdc_list = $(wjdc_list).append('<li><label class="demo--label" onselectstart="return false;" style="-moz-user-select:none;margin:0;"><input type="radio" name="a" value="" class="demo--radio1" /><span class="demo--radio1Input"></span><span class="demo_span">26~30</span></label></li>');
            wjdc_list = $(wjdc_list).append('<li><label class="demo--label" onselectstart="return false;" style="-moz-user-select:none;margin:0;"><input type="radio" name="a" value="" class="demo--radio1" /><span class="demo--radio1Input"></span><span class="demo_span">31~40</span></label></li>');
            wjdc_list = $(wjdc_list).append('<li><label class="demo--label" onselectstart="return false;" style="-moz-user-select:none;margin:0;"><input type="radio" name="a" value="" class="demo--radio1" /><span class="demo--radio1Input"></span><span class="demo_span">41~50</span></label></li>');
            wjdc_list = $(wjdc_list).append('<li><label class="demo--label" onselectstart="return false;" style="-moz-user-select:none;margin:0;"><input type="radio" name="a" value="" class="demo--radio1" /><span class="demo--radio1Input"></span><span class="demo_span">51~60</span></label></li>');
            wjdc_list = $(wjdc_list).append('<li><label class="demo--label" onselectstart="return false;" style="-moz-user-select:none;margin:0;"><input type="radio" name="a" value="" class="demo--radio1" /><span class="demo--radio1Input"></span><span class="demo_span">60岁以上</span></label></li>');
        }
        
        if (index == "8") {
        	wjdc_list = $(wjdc_list).append('<li><div class="tm_btitlt"><i class="nmb" >' + Grade + '</i><i class="btwenzi">'+title+'</i><span class="tip_wz">' + danxuan + '</span></div></li>');
            wjdc_list = $(wjdc_list).append('<img style="max-height: 200px;" class="add-img imgshow" src="">');
            //wjdc_list = $(wjdc_list).append('<li><div class="tm_btitlt"><i class="btwenzi">段落文字说明</i></div></li>');
        }
        if (index == "10") {
            $(wjdc_list).append('<li style="height:30px;margin:10px;"><label><input type="hidden" class="single-slider" value="0" /></label></li>');
        	console.log(wjdc_list);
        	
			setTimeout(function(){  
				$('.single-slider').jRange({
					from: 0,
					to: 100,
					step: 1,
					scale: [0,25,50,75,100],
					format: '%s',
					width: 500,
					showLabels: true,
					showScale: true
				});
			}, 100); 

        }
        if (index == "11") {
        	wjdc_list = $(wjdc_list).append('<li><div class="pc_diqu_d1" data-toggle="distpicker"><select></select></div></li>'); 
        	setTimeout(function(){ 
        		$('[data-toggle="distpicker"]').distpicker({
			  		autoSelect: false
				});
        	}, 100); 
        }
        if (index == "12") {
            wjdc_list = $(wjdc_list).append('<li><div class="pc_diqu_d1" data-toggle="distpicker"><select></select><select></select></div></li>'); 
        	setTimeout(function(){ 
        		$('[data-toggle="distpicker"]').distpicker({
			  		autoSelect: false
				});
        	}, 100);
        }
        if (index == "13") {
           	wjdc_list = $(wjdc_list).append('<li><div class="pc_diqu_d1" data-toggle="distpicker"><select></select><select></select><select></select></div></li>'); 
        	setTimeout(function(){ 
        		$('[data-toggle="distpicker"]').distpicker({
			  		autoSelect: false
				});
        	}, 100);
        }
        if (index == "14") {
            wjdc_list = $(wjdc_list).append('<li><label style="position:relative;"><textarea id="mobile" placeholder="请输入手机号码" name="" cols="" rows="" class="input_wenbk btwen_text btwen_text_dx" style="resize:none;max-height:33px;width:35%;display:block;padding-left:5%;"></textarea><i style="position:absolute;left:0;top:6px;font-size:20px;color:#999;width:5%;text-align:center;" class="layui-icon layui-icon-cellphone"></i><textarea placeholder="请输入手机验证码" name="" cols="" rows="" class="input_wenbk btwen_text btwen_text_dx" style="resize:none;max-height:33px;width:26%;margin-top:8px; padding-left:5%;"></textarea><div onclick="do_code(this)"  style="width:80px;display:inline-block;position:absolute;top:41px; cursor:pointer; height:33px;background:#777;color:#fff;line-height:35px;text-align:center;">发送验证码</div><i style="position:absolute;left:0;top:50px;font-size:20px;color:#999;width:5%;text-align:center;" class="layui-icon layui-icon-vercode"></i></label> </li>');
        }
        if (index == "15") {
            wjdc_list = $(wjdc_list).append('<li><label style="position:relative;"> <textarea name="" cols="" rows="" class="input_wenbk btwen_text btwen_text_dx" style="resize:none;max-height:33px;width:26%;padding-left:5%;"></textarea><i style="position:absolute;left:0;top:8px;color:#999;width:5%;text-align:center;"><img style="width:20px;" src="../static/images/email.png"/><i></label> </li>');
        }
        if (index == "16") {
            wjdc_list = $(wjdc_list).append('<li><label style="position:relative;"><textarea id="J-xl-3'+max_xh+'" name="" cols="" rows="" class="input_wenbk btwen_text btwen_text_dx" style="resize:none;max-height:33px;width:26%;padding-left:5%;"></textarea><i style="position:absolute;left:0;top:8px;color:#999;width:5%;text-align:center;"><img style="width:20px;" src="../static/images/dateIco.png"><i></i></i></label><i style="position:absolute;left:0;top:8px;color:#999;width:5%;text-align:center;"><i> </i></i></li>');
			setTimeout(function(){  
				//出生日期
				laydate({
				    elem: "#J-xl-3"+max_xh
				});
			}, 100); 
        }
        if (index == "17") {
            wjdc_list = $(wjdc_list).append('<li><label><select class="zhiye_slt"><option value="">请选择</option><option value="">全日制学生</option><option value="">生产人员</option> <option value="">销售人员</option> <option value="">市场/公关人员</option><option value="">客服人员</option> <option value="">行政/后勤人员</option> <option value="">人力资源</option> <option value="">财务/审计人员</option> <option value="">文职/办事人员</option> <option value="">技术/研发人员</option> <option value="">管理人员</option> <option value="">教师</option> <option value="">顾问/咨询</option><option value="">其他</option> </select></label></li>');
        }
        if (index == "18") {
            wjdc_list = $(wjdc_list).append('<li><label><select class="zhiye_slt"> <option value="">请选择</option> <option value="">IT/软硬件服务/电子商务/因特网运营</option> <option value="">快速消费品(食品/饮料/化妆品)</option> <option value="">批发/零售</option> <option value="">服装/纺织/皮革</option> <option value="">家具/工艺品/玩具</option> <option value="">教育/培训/科研/院校</option> <option value="">家电</option> <option value="">通信/电信运营/网络设备/增值服务</option> <option value="">制造业</option> <option value="">汽车及零配件</option> <option value="">餐饮/娱乐/旅游/酒店/生活服务</option> <option value="">办公用品及设备</option> <option value="">会计/审计</option> <option value="">法律</option> <option value="">银行/保险/证券/投资银行/风险基金</option> <option value="">电子技术/半导体/集成电路</option> <option value="">仪器仪表/工业自动化</option> <option value="">贸易/进出口</option> <option value="">机械/设备/重工</option> <option value="">制药/生物工程/医疗设备/器械</option> <option value="">医疗/护理/保健/卫生</option> <option value="">广告/公关/媒体/艺术</option> <option value="">出版/印刷/包装</option> <option value="">房地产开发/建筑工程/装潢/设计</option> <option value="">物业管理/商业中心</option> <option value="">中介/咨询/猎头/认证</option> <option value="">交通/运输/物流</option> <option value="">航天/航空/能源/化工</option> <option value="">农业/渔业/林业</option> <option value="">其他行业</option> </select></label></li>');
        }
        if (index == "19") {
            wjdc_list = $(wjdc_list).append('<li><label><div class="xzw_starSys"><div class="xzw_starBox"><ul class="star stars"><li index_d="0"><span class="" style="left: 0px; width: 30px;">不满意</span></li><li index_d="1"><span class="" style="left: 30px; width: 30px;">一般</span></li><li index_d="2"><span class="" style="left:60px;">还不错</span></li><li index_d="3"><span class="" style="left:90px;">很好</span></li><li index_d="4"><span class="" style="left:120px;">无可挑剔</span></li></ul><div class="current-rating showb"></div></div><div class="description"></div></div></label></li>');
       		$(wjdc_list).find('.stars li').each(function() {
       			$(this).find('span').css("left",$(this).index()*30+"px");										
		    });     		
       		setTimeout(function(){
       			description();
       	 	}, 100); 
        }
       	
       	if($('.insert_box').length=='1'){	
			$('.insert_box').append(wjdc_list);
        	$('.insert_box').append('<div class="dx_box" data-t="' + index + '"></div>');
        	$('.insert_box').attr('flag','insert');
        	$('.insert_box').addClass('movie_box');
        	if (index != "8") {
        		$('.insert_box').addClass('box_xh');
        	}else{
        		$('.insert_box').addClass('duanluo_xh');
        	}
        	$('.insert_box').removeClass('insert_box');
        	
        	$('.box_xh').each(function(e){
				if($(this).find(".dx_box").attr("data-t") != "8"){
					$(this).find('.nmb').html(e+1);
				}
			})
        	$('.charuxinti').hide();		
			$('.movie_box').css({
				"border": "1px solid #fff"
			});
			$('.movie_box').children(".kzqy_czbut").remove();
		}else{
			movie_box = $(movie_box).append(wjdc_list);
        	movie_box = $(movie_box).append('<div class="dx_box" data-t="' + index + '"></div>');
        	$(".yd_box").append(movie_box);
        	$("html,body").animate({
		        scrollTop: document.body.clientHeight
		    },500);
		}	
		
    }
	
	
$(document).ready(function(e) {
	
	//鼠标移上去显示按钮
	$(document).on("mouseenter",".movie_box", function() {	
		var flag = $(this).children(".kzqy_czbut").find('.le_a').attr('flag');
		if(flag!=2){
			var html_cz = "<div class='kzqy_czbut'><span class='le_a' flag='1'><i class='layui-icon layui-icon-add-circle-fine' style='font-size: 14px;padding-top:2px;padding-right:2px;'></i>在此题后插入新题</span><a href='javascript:void(0)' class='sy'>上移</a><a href='javascript:void(0)'  class='xy'>下移</a><a href='javascript:void(0)'  class='bianji'>编辑</a><a href='javascript:void(0)'  class='copy'>复制</a><a href='javascript:void(0)' class='del' >删除</a></div>"
			$(this).css({
				"border": "1px solid #393d49"
			});
			$(this).children(".wjdc_list").after(html_cz);
		 	if( $(this).children(".dx_box").attr('flag')==1 ){
	    		$(this).find(".bianji").siblings().hide();
	    	}
		}
	});
	
	$(document).on("mouseleave",".movie_box", function() {
		var flag = $(this).children(".kzqy_czbut").find('.le_a').attr('flag');
		if(flag==1){
			$(this).css({
				"border": "1px solid #fff"
			});
			$(this).children(".kzqy_czbut").remove();
		}	
	});
	//下移 
	$(document).on("click",".xy", function() {
		le_cleal($(this));
		
		//文字的长度 
		var leng = $(".yd_box").children(".movie_box").length;
		var dqgs = $(this).parent(".kzqy_czbut").parent(".movie_box").index();
		if(dqgs < leng - 1) {
			var czxx = $(this).parent(".kzqy_czbut").parent(".movie_box");
			var dq_tmid = czxx.find(".dq_tmid").val();
			var other_tmid = czxx.next().find(".dq_tmid").val();
			var xyghtml = czxx.next().children().clone();
			var syghtml = czxx.children().clone();
			
			var xy_tj = czxx.next().hasClass("is_tj");
			var sy_tj = czxx.hasClass("is_tj");
			
			if(xy_tj == true && sy_tj == false){
				czxx.addClass("is_tj");
				czxx.next().removeClass("is_tj");
			}
			
			if(sy_tj == true && xy_tj == false){
				czxx.removeClass("is_tj");
				czxx.next().addClass("is_tj");
			}
			
			czxx.next().html(syghtml);
			czxx.html(xyghtml);
			//题目类型
			var xygtype = czxx.next().find('.dx_box').attr('data-t');
			var sygtype = czxx.find('.dx_box').attr('data-t');			
			if(xygtype!='8' && sygtype!='8'){
				czxx.children(".wjdc_list").find(".nmb").text(dqgs + 1);
				czxx.next().children(".wjdc_list").find(".nmb").text(dqgs + 2);	
			}
			//更新序号
			//var dqxh = czxx.attr('xh');			
			change_xh('down',dqgs+1,dq_tmid,other_tmid);
		} else {
			layer.msg('到底了', {icon: 2,offset: '40%',time:1500,shade: 0.3});
		}
	});
	//上移
	$(document).on("click",".sy", function() {	
		le_cleal($(this));
		
		var dqgs = $(this).parent(".kzqy_czbut").parent(".movie_box").index();
		if(dqgs > 0) {
			var czxx = $(this).parent(".kzqy_czbut").parent(".movie_box");
			var dq_tmid = czxx.find(".dq_tmid").val();
			var other_tmid = czxx.prev().find(".dq_tmid").val();
			var xyghtml = czxx.prev().children().clone();
			var syghtml = czxx.children().clone();
			czxx.prev().html(syghtml);
			czxx.html(xyghtml);
			
			var xy_tj = czxx.prev().hasClass("is_tj");
			var sy_tj = czxx.hasClass("is_tj");
			
			if(xy_tj == true && sy_tj == false){
				czxx.addClass("is_tj");
				czxx.prev().removeClass("is_tj");
			}
			
			if(sy_tj == true && xy_tj == false){
				czxx.removeClass("is_tj");
				czxx.prev().addClass("is_tj");
			}
			
			//题目类型
			var xygtype = czxx.prev().find('.dx_box').attr('data-t');
			var sygtype = czxx.find('.dx_box').attr('data-t');
			if(xygtype!='8' && sygtype!='8'){		
				czxx.children(".wjdc_list").find(".nmb").text(dqgs + 1);			
				czxx.prev().children(".wjdc_list").find(".nmb").text(dqgs);
			}
			//序号
			//var dqxh = czxx.attr('xh');			
			change_xh('up',dqgs+1,dq_tmid,other_tmid);
		} else {
			layer.msg('到头了', {icon: 2,offset: '40%',time:1500,shade: 0.3});
		}
	});

	$(document).on("click",".del", function() {
		le_cleal($(this));
		question_del(this);
	});

	$(document).on("click", ".bianji",function() {
		
		le_cleal($(this));
			
		//编辑的时候禁止其他操作   
		$(this).siblings().hide();

		//接受编辑内容的容器
		var dx_rq = $(this).parent(".kzqy_czbut").parent(".movie_box").find(".dx_box");
		var title = dx_rq.attr("data-t");

		//是否初次编辑
		var is_first = $(this).parent(".kzqy_czbut").parent(".movie_box").children(".dx_box").html();
		
		if(is_first==''){
			dx_rq.attr('flag',1);						
			if(title == 0){
				var htmls = $(".dxuan").html();
			}else if(title == 1){
				var htmls = $(".duoxuan").html();
			}else if(title == 2){
				var htmls = $(".tktm").html();
			}else if(title == 3){
				var htmls = $(".wdtm").html();
			}else if(title == 4){
				var htmls = $(".wenjian").html();
			}else if(title == 5){
				var htmls = $(".xingming").html();
			}else if(title == 6){
				var htmls = $(".xingbie").html();
			}else if(title == 7){
				var htmls = $(".nianling").html();
			}else if(title == 8){
				var htmls = $(".duanluo").html();
			}else if(title == 10){
				var htmls = $(".bizhong").html();
			}else if(title == 11){
				var htmls = $(".chengshi").html();			
			}else if(title == 12){
				var htmls = $(".chengshi1").html();
			}else if(title == 13){
				var htmls = $(".chengshi2").html();
			}else if(title == 14){
				var htmls = $(".shouji").html();
			}else if(title == 15){
				var htmls = $(".email").html();
			}else if(title == 16){
				var htmls = $(".riqi").html();
			}else if(title == 17){
				var htmls = $(".zhiye").html();
			}else if(title == 18){
				var htmls = $(".hangye").html();
			}else if(title == 19){
				var htmls = $(".pingfen").html();
			}else if(title == 20){
				var htmls = $(".toupiao").html();
			}						
			var str='';
			str += 	'<div class="picture_d1 upload_img">';
			str += 		'<div class="picture_d2">';
			str +=			'<div style="width: 100%;height: 44px;border-bottom: 1px solid #f5f5f5;text-align: center;font-size: 15px;color: #333;line-height: 44px;">上传题目图片</div>';
			str +=			'<div class="z_photo upimg-div" >';
			str +=				'<section class="z_file">';
			str +=					'<div class="del_show" style="cursor:pointer;width: 220px;height: 40px;background: rgba(0,0,0,0.5);position: absolute;top: 0px;left: 50%;margin-left: -110px;font-size: 14px;color: #fff;text-align: center;line-height: 40px;display: none;">删除</div>';
			str +=					'<img class="imghead add-img" src="../static/images/a11.png" >';		            		
			str +=					'<input style="display: none;" type="file" class="title_img file" multiple />';
			str +=				'</section>';
			str +=			'</div>';		
			str +=			'<div class="picture_d3">关闭</div>';
			str +=		'</div>';
			str +=	'</div>';
			
			var str0 = '';
			str0 += '<div class="picture_d1 limit_num_div">';
			str0 += '	<div class="picture_d2" style="min-height: 270px;">';
			str0 += '		<div style="width: 100%;height: 44px;border-bottom: 1px solid #f5f5f5;text-align: center;font-size: 15px;color: #333;line-height: 44px;">设置多选最多选择数量</div>';
			str0 += '		<div class="duox_box">';
			str0 += '			<div class="duox_box_l" onclick="reduce(this)">-</div>';
			str0 += '			<div class="duox_box_c">';
			str0 += '				<input type="text" class="limit_num" name="limit_num" value="0">';
			str0 += '			</div>';
			str0 += '			<div class="duox_box_r" onclick="add(this)">+</div>';
			str0 += '		</div>';
			str0 += '		<div class="picture_d3 limit_num_btn" style="margin-top:0;" onclick="close(this)">关闭</div>';
			str0 += '	</div>';
			str0 += '</div>';
			
			var str1 = '';
			str1 += '<div class="tc" style="display: none;position: fixed;top: 0;left: 0;z-index: 1000; width: 100%;height: 100%;background: rgba(0,0,0,0.6);">';
			str1 += '	<div id="tc"  class="tc1" style="display: none;overflow-y:auto;">';
			str1 += '		<div style="margin:50px 50px 20px 50px;">';
			str1 += '			<label><b>当前题目：</b></label>';
			str1 += '			<input  class="dq_tmid" type="hidden" value="" />';
			str1 += '			<input  class="pd" type="hidden" value="" />';
			str1 += '			<input  class="cf" type="hidden" value="" />';
			str1 += '			<span class="dq_tm"></span>';
			str1 += '		</div>';
			str1 += '		<div class="gl_xlk">';
			str1 += '			<div class="gl_xlk0" style="margin:10px 50px;">';
			str1 += '				<label><b>关联题目<b class="tc_xh"></b>：</b></label>';
			str1 += '				<select name="" style="width: 70%;height: 30px;" onchange="getGlOption(this)" id="gl_tm0" class="gl_tm">';
			str1 += '				</select>';
			str1 += '				<a href="javascript:void(0);" class="gd" onclick="operateGl(this)">+更多</a>';
			str1 += '				<div id="tmxx0" class="tmxx" style="margin:18px 0 0 74px;display: none;">';
			str1 += '					<table>';
			str1 += '						<tbody>';
			str1 += '							<tr>';
			str1 += '								<td>';
			str1 += ' 									<font color="red">';
			str1 += '										<b style="padding-bottom:10px;display: block;">';
			str1 += '											当“关联题目”选择下面的打勾的选项中任意一个，当前题才出现';
			str1 += '										</b>';
			str1 += '									</font>';
			str1 += '								</td>';
			str1 += '							</tr>';
			str1 += '							<tr>';
			str1 += '								<td>';
			str1 += '									<div id="gl_xx0" class="gl_xx">';							
			str1 += '									</div>';								
			str1 += '								</td>';		
			str1 += '							</tr>';
			str1 += '						</tbody>';
			str1 += '					</table>';	
			str1 += '				</div>';
			str1 += '			</div>';
			str1 += '		</div>';
			str1 += '		<div class="gl_fs" style="margin-left: 50px;display: none;">';
			str1 += '			<label><b>关联多题时：</b></label>多题之间';
			str1 += '			<input name="fs" class="and" value="and" type="radio" /><span style="margin: 0 5px;">为“且”的关系</span>';
			str1 += '			<input name="fs" class="or" value="or" type="radio" checked /><span style="margin: 0 5px;">为“或”的关系</span>';
			str1 += '		</div>';
			str1 += '		<center>';
			str1 += '			<span class="del_gl" style="margin-top: 30px;">';
			str1 += '				<input type="button" class="picture_d4" onclick="saveGlOption(this)" value="确定" />';
			str1 += '			</span>';
			str1 += '		</center>';		
			str1 += '	</div>';
			str1 += '</div>';
			
			dx_rq.append(str);
			dx_rq.append(str0);
			dx_rq.append(str1);
			dx_rq.append(htmls);
			dx_rq.show();
			var texte_bt_val = $(this).parents(".movie_box").find(".btwenzi").text();	
			dx_rq.find(".btwen_text").val(texte_bt_val);			
			dx_rq.find('.btwen_text').editable({
			 	inlineMode: false,
			 	language: "zh_cn",
			 	alwaysBlank: true, 
			 	buttons: ['bold', 'italic', 'underline','strikeThrough','fontSize', 'fontFamily', 'color', 'align', 'outdent', 'indent', 'createLink','insertHorizontalRule','undo','redo','html']
			})
		}else{
			$(this).parent(".kzqy_czbut").parent(".movie_box").children(".dx_box").attr('flag',1).show();			
		}
	});
	//取消编辑
	$(document).on("click",".dx_box .qxbj_but", function() {
		$(this).parent(".bjqxwc_box").parent(".dx_box").hide();
		$(".movie_box").css({
			"border": "1px solid #fff"
		});
		$(".kzqy_czbut").remove();           
	});
	//完成编辑（编辑）
	$(document).on("click", ".swcbj_but",function() {
		//标记已入库
		$(this).parents(".movie_box").removeClass('is_tj');
				
		$(".bianji").siblings().show();
		var jcxxxx = $(this).parent(".bjqxwc_box").parent(".dx_box"); //编辑题目区
		
		var querstionType = jcxxxx.attr("data-t"); //获取题目类型
		var form = $(this).parents(".dx_box").find('form').get(0);
		var formData = new FormData(form);
		
		var limit_num = $(this).parents(".movie_box").find(".limit_num").val();
		
		formData.append('limit_num',limit_num);

		//题目标题
		var contents = jcxxxx.find(".froala-element").html(); //获取问题题目
		jcxxxx.parent(".movie_box").children(".wjdc_list").children("li").eq(0).find(".tm_btitlt").children(".btwenzi").html(contents); //将修改过的问题题目展示
		
		/*var flag = $(this).parents(".movie_box").attr('flag');
		//插入的题
		if(flag=='insert'){
			var index = $(this).parents(".movie_box").index();
			var dq_tmid = $(this).parents(".movie_box").find(".dq_tmid").val();
			
			for (var i=0;i<index;i++){
				if( $(".movie_box").eq(i).attr('flag') != 'insert' ){
					var xh = $(".movie_box").eq(i).attr('xh');					
				}
			}

			formData.append('xh',index);
			formData.append('type',querstionType);
			//formData.append('flag',2);	
			formData.append('dq_tmid',dq_tmid);	

			var cu_xh = question_post(formData);
			
			cu_xh = JSON.parse(cu_xh);

			if(cu_xh['xh'] != undefined){
				$(this).parents(".movie_box").attr('xh',cu_xh['xh']);
				//$(this).parents(".movie_box").attr('flag','');
				
				var id = $(this).parents(".movie_box").find(".dq_tmid").val();
				if(id == ""){
					$(this).parents(".movie_box").find(".dq_tmid").val(cu_xh['id']);
				}
				
				//重新编号
				$(this).parents(".yd_box").find(".movie_box").each(function(e) {			
					dqxh = $(this).index();	
					//console.log(dqxh);
					if( dqxh>index ){
						var xh = Number($(this).attr('xh'))+1; 
						$(this).attr('xh',xh);
					}			
				});
			}									
		}else{
			var xh = $(this).parents(".movie_box").attr('xh');
			var dq_tmid = $(this).parents(".movie_box").find(".dq_tmid").val();
			
			formData.append('xh',xh);
			formData.append('type',querstionType);
			formData.append('flag',1);	
			formData.append('dq_tmid',dq_tmid);	
			//console.log(formData.get("title_img"));
			var cu_xh = question_post(formData);
			
			var id = $(this).parents(".movie_box").find(".dq_tmid").val();
			if(id == ""){
				$(this).parents(".movie_box").find(".dq_tmid").val(cu_xh['id']);
			}
		}*/

		var index = $(this).parents(".movie_box").index();
		var dq_tmid = $(this).parents(".movie_box").find(".dq_tmid").val();

		formData.append('xh',index);
		formData.append('type',querstionType);
		formData.append('dq_tmid',dq_tmid);
		let cu_xh = question_post(formData, 2);
		let answer_ids = [];
		if(cu_xh && cu_xh['answer_ids']){
			answer_ids = cu_xh['answer_ids'];
		}
		$(this).parents(".movie_box").attr('xh',cu_xh['xh']);
		$(this).parents(".movie_box").find('.gl_fs').find(".and").attr('name', "fs" + cu_xh['xh']);
		$(this).parents(".movie_box").find('.gl_fs').find(".or").attr('name', "fs" + cu_xh['xh']);
		$(this).parents(".movie_box").attr('id','tm_id'+cu_xh['id']);
		$(this).parents(".movie_box").find(".dq_tmid").val(cu_xh['id']);
		$(this).parents(".movie_box").find(".title_itram").children(".kzjxx_iteam").each(function (j) {
			$(this).find(".answer_ids").val(answer_ids[j]);
		})

		switch(querstionType) {
			case "0": //单选				
			case "1": //多选
			case "6": 	
			case "7": 
			case "20": 	
			case "21": 
				//编辑题目选项的个数				
				var bjtm_xm_length = jcxxxx.find(".title_itram").children(".kzjxx_iteam").length; //编辑选项的 选项个数
				var xmtit_length = jcxxxx.parent(".movie_box").children(".wjdc_list").children("li").length - 1; //题目选择的个数

				//删除选项
				for(var toljs = xmtit_length; toljs > 0; toljs--) {
					jcxxxx.parent(".movie_box").children(".wjdc_list").children("li").eq(toljs).remove();
				}
				
				//是否必填
				jcxxxx.find(".demo--radio").val();
				
				//遍历题目项目的文字				
				jcxxxx.children("form").children(".title_itram").children(".kzjxx_iteam").each(function(ev) {
					//题目选项
					var texte_val_bj = $(this).find(".input_wenbk").val(); //获取填写信息
											
					if(querstionType == "1") {
						var li = '<li><label class="demo--label" onselectstart="return false;" style="-moz-user-select:none;margin:0;"><input type="checkbox" name="a" value="" class="demo--radio" /><span class="demo--radioInput"></span> <span class="demo_span">'+texte_val_bj+'</span></label></li>';
					}else{
						var li = '<li><label class="demo--label1" onselectstart="return false;" style="-moz-user-select:none;margin:0;"><input type="radio" name="a" value="" class="demo--radio1" /><span class="demo--radio1Input"></span><span class="demo_span">'+texte_val_bj+'</span></label></li>';
					}																
					
					jcxxxx.parent(".movie_box").children(".wjdc_list").append(li);	
				});
				break;				
			case "14":					
				var beiyong = jcxxxx.find("input[name=beiyong]:checked").size(); 
				if(beiyong!=0){
					$(this).parents(".movie_box").find('.yz_show').show();
				}else{
					$(this).parents(".movie_box").find('.yz_show').hide();
				}				
				break;
			case "17":
			case "18":
				var str = "<option value=''>请选择</option>";
				jcxxxx.find('.kzjxx_iteam').each(function(){
					str += "<option value=''>"+$(this).find('.input_wenbk').val()+"</option>";
				})
				$(this).parents(".movie_box").find('.zhiye_slt').html(str);
				break;
			case "19":						
				var arr = new Array();
				var str = '';
				//遍历题目项目的文字				
				jcxxxx.find(".kzjxx_iteam").each(function(ev) {
					//题目选项
					var texte_val_bj = $(this).find(".input_wenbk").val(); 
					
					arr.push(texte_val_bj);
									
					str += '<li index_d="'+ev+'"><span style="left:'+(ev*30)+'px">'+texte_val_bj+'</span></li>';														
				});	
				$(this).parents(".movie_box").find('.star').css('width',arr.length*30+"px");	

				if(Number($(this).parents(".movie_box").find('.showb').width())>arr.length*30){					
					$(this).parents(".movie_box").find('.showb').css('width',arr.length*30+"px");
				}
				$(this).parents(".movie_box").find('.stars').html(str);
				description(arr);				
				break;
		}
		//清除     
		$(this).parent(".bjqxwc_box").parent(".dx_box").attr('flag',0).hide();
	});
	//选项上移
	$(document).on("click",".option_sy", function() {
		// 找到选项区
		var jcxxxx = $(this).parent(".sxzy").parent(".kzjxx_iteam"); //编辑题目区s
		// 找到选项区的编辑题目区
		var dqgs =  $(this).parent(".sxzy").parents(".kzjxx_iteam").index();
			
		if(dqgs > 0) {
			// 获得上一个选项的value值
			var prev = jcxxxx.prev().find(".input_wenbk").val();
			// 获得当前选项的value值
			var next = jcxxxx.find(".input_wenbk").val();
			// 把上一个选项的值赋值到当前选项
			jcxxxx.find(".input_wenbk").val(prev);
			// 把当前选项的值赋值到下一个选项
			jcxxxx.prev().find(".input_wenbk").val(next);
		} else {
			layer.msg('到头了', {icon: 2,offset: '40%',time:1500,shade: 0.3});
		}
	});
	//选项下移
	$(document).on("click", ".option_xy",function() {
		// 找到选项区
		var jcxxxx = $(this).parent(".sxzy").parent(".kzjxx_iteam"); //编辑题目区s
		// 找到选项区的编辑题目区
		var jcxxx = jcxxxx .parent(".title_itram").parents(".dx_box");
		// 获得题目选项的个数
		var bjtm_xm_length = jcxxx.find(".title_itram").children(".kzjxx_iteam").length; //编辑选项的 选项个数
		// 获得该选项在第几个
		var dqgs =  $(this).parent(".sxzy").parents(".kzjxx_iteam").index();
		if(dqgs < bjtm_xm_length - 1) {
			// 获得下一个选项的value值
			var next = jcxxxx.next().find(".input_wenbk").val();
			// 获得当前选项的value值
			var find = jcxxxx.find(".input_wenbk").val();
			// 把下一个选项的值赋值到当前选项
			jcxxxx.find(".input_wenbk").val(next);
			// 把当前选项的值赋值到下一个选项
			jcxxxx.next().find(".input_wenbk").val(find);
		} else {
			layer.msg('到底了', {icon: 2,offset: '40%',time:1500,shade: 0.3});
		}
	});
	//文件
	$(document).on("click", ".is_limit",function() {	
		if($(this).find('input').is(':checked')){
       		$(this).siblings('.wenjian_div1').show();
	    }else{
	      	$(this).siblings('.wenjian_div1').hide();
	    }
	});
	
	$(document).on("click", ".type_all",function() {
		if($(this).find('input').is(':checked')){
       		$(this).siblings('label').find('input').click();
	    }else{
	    	$(this).siblings('label').find('input').each(function(){
	    		if( $(this).is(':checked') ){
		    		$(this).click();
		    	} 
	    	})	    	       
	    }	
	});
	
	//必填
	$(document).on("click", "input[name='required']",function() {	
		if($(this).is(':checked')){
			$(this).parents(".movie_box").find(".tm_btitlt").prepend('<i class="is_bt"><font color="red" size="4px">*</font></i>');
	    }else{
			$(this).parents(".movie_box").find(".tm_btitlt .is_bt").remove();
	    }
	});
	
	//此题后添加
	$(document).on("click", ".le_a",function() {	
		$flag = $(this).attr('flag');
    	if($flag=='1'){
    		$('.charuxinti').show();
    		$(this).siblings().remove();   		
    		$(this).parents('.movie_box').siblings().css({
                "border": "1px solid #fff"
            });
            $(this).parents('.movie_box').siblings().children(".kzqy_czbut").remove();
    		$(this).html('取消插入点');
    		$(this).attr('flag','2');    		
    		$('.insert_box').remove();
    		$(this).parents('.movie_box').after('<div class="insert_box is_tj" style="border: 1px solid rgb(255, 255, 255);"></div>');
    	}else{
    		$('.charuxinti').hide();
    		$(this).html("<i class='layui-icon layui-icon-add-circle-fine' style='font-size: 14px;padding-top:2px;padding-right:2px;'></i>在此题后插入新题");
    		$(this).attr('flag','1');
    		$('.insert_box').remove();
    	}    	
	});
	
	function le_cleal($this){		
		$('.charuxinti').hide();		
		$this.parents('.movie_box').siblings().css({
			"border": "1px solid #fff"
		});
		$this.parents('.movie_box').siblings().children(".kzqy_czbut").remove();		
		$('.insert_box').remove();
	}	
	
	//段落
	/*$(document).on("change", ".changeduanluo",function() {
		if($(this).val()=='1'){
			$(this).siblings('.froala-box').show();
			$(this).siblings('.picture_d2').hide();
		}else{
			$(this).siblings('.froala-box').hide();
			$(this).siblings('.picture_d2').show();
		}
	});*/
	
	//图片上传
	$(document).on("click", ".zjxx1",function() {	
    	$(this).parents('.dx_box').find('.upload_img').show();//那么就显示div 
	});
	
	$(document).on("click", ".picture_d3",function() {		
    	$(this).parents('.dx_box').find('.upload_img').hide();
	});
	
	// 多选数量限制
	$(document).on("click", ".limit_num_btn",function() {		
    	$(this).parents('.dx_box').find('.limit_num_div').hide();
	});
	
	$(document).on("click", ".imghead",function() {		
		$(this).siblings(".title_img").click();
	})

	$(document).on("click", ".del_show",function() {			
    	$(this).siblings(".imghead").attr("src","../static/images/a11.png");
		$(this).parents(".movie_box").find('.imgshow').hide();
		$(this).parents(".movie_box").find('.imgshow').attr("src", "");
		$(this).parents(".movie_box").find(".question_img").val('');
    	$(this).parents(".picture_d2").find(".del_show").hide();
	});
});